<template>
	<view class="service_wrap">
		<view class="info_item">
			<view class="input_wrap">
				<view style="font-weight: bold;font-size: 32rpx;">{{ detail.name }}</view>
			</view>
			<view class="input_wrap">
				<view class="left_text">所属行业：</view>
				<view class="row_1" style="width: 83%;">{{ detail.industries }}</view>
			</view>
			<view class="input_wrap">
				<view class="left_text">地址：</view>
				<view  class="row_1" style="width: 90%;">{{detail.address}}</view>
			</view>
			<view class="input_wrap" v-if="detail.is_school == 1">
				<view class="left_text">标签：</view>
				<view style="color: #1C41F1;">{{detail.is_school == 1 ? '校友企业' : ''}}</view>
			</view>
		</view>
		<view class="info_item">
			<view class="title">公司介绍</view>
			<view style="margin-bottom: 10rpx;font-size: 32rpx;">{{ detail.name }}</view>
			<view style="color: #00000050;font-size: 26rpx;">{{ detail.introduce }}</view>
		</view>
		<view class="info_item" v-if="detail.scope != ''">
			<view class="title">经营范围</view>
			<view style="color: #00000050;font-size: 26rpx;">{{ detail.scope }}</view>
		</view>
		<view class="info_item" v-if="detail.merit != ''">
			<view class="title">公司优势</view>
			<view style="color: #00000050;font-size: 26rpx;">{{ detail.merit }}</view>
		</view>
		<view class="info_item">
			<view class="title">图片</view>
			<view style="display: flex;flex-wrap: wrap;" v-if="is_array">
				<view class="add_item" style="margin-left: 20rpx;" v-for="(item,index) in detail.images">
					<image class="up_img" @click="toOpen(index)" :src="ossUrl + item.url" mode="aspectFit"></image>
				</view>
			</view>
			<view class="add_item" v-else>
				<image class="up_img" @click="toOpen()" :src="ossUrl + detail.images" mode="aspectFit"></image>
			</view>
		</view>
		<view class="bot_btn">
			<button class="share" open-type="share">分享</button>
			<view class="btn" @click="callPhone()">联系</view>
		</view>
	</view>
</template>

<script>
	import { ossUrl } from '../../../utils/config';
	import {
		companyDetail
	} from '@/api/home.js'
	import { replaceSpecialChar } from '@/utils/tools.js'
	export default {
		data() {
			return {
				ossUrl: ossUrl,
				detail: '',
				is_array: null
			};
		},
		onLoad(options) {
			this.companyDetailFun(options.id)
		},
		onShareAppMessage(res) { //发送给朋友
			return {
				title: '小程序分享',
				imageUrl: '',
			}
		},
		methods: {
			companyDetailFun(id) {
				companyDetail({
					id
				}).then(res => {
					if (res.code == 1) {
						if (res.data.images.indexOf('[') > -1) {
							this.is_array = true
							res.data.images = JSON.parse(replaceSpecialChar(res.data.images))
						}
						this.detail = res.data
					}
				})
			},
			toOpen(index) {
				if (this.is_array) {
					let url = []
					this.detail.images.forEach(item => {
						url.push(ossUrl + item.url)
					})
					uni.previewImage({
						urls: url,
						current: url[index]
					})
				}else {
					let url = [this.ossUrl + this.detail.images]
					uni.previewImage({
						urls: url
					})
				}
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.detail.mobile
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.service_wrap {
	min-height: 100vh;
	background: #F5F5F5;
	padding-top: 20rpx;
	padding-bottom: 150rpx;
	.info_item {
		width: 690rpx;
		// height: 420rpx;
		background: #fff;
		border-radius: 24rpx;
		margin: 0 auto 20rpx;
		padding: 26rpx;
		
		.title {
			font-size: 32rpx;
			font-weight: bold;
			margin-bottom: 20rpx;
		}
		.input_wrap {
			display: flex;
			padding: 0rpx 0 10rpx 0;
			font-size: 26rpx;
			.right_icon {
				width: 15rpx;
				height: 24rpx;
			}
			.picker {
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
		}
	
		.add_item {
			width: 180rpx;
			height: 160rpx;
			border-radius: 12rpx;
			.up_img {
				width: 100%;
				height: 100%;
				border-radius: 12rpx;
			}
		}
	}

	.bot_btn {
		width: 100vw;
		height: 150rpx;
		background: #FFFFFF;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 2;
		display: flex;
		align-items: center;
		.share {
			width: 300rpx;
			height: 80rpx;
			line-height: 80rpx;
			margin: 0 auto;
			text-align: center;
			color: #1C41F1;
			font-size: 28rpx;
			border: 1px solid #1C41F1;
			background: transparent;
			box-sizing: border-box;
			transform: rotateZ(360deg);
			border-radius: 54rpx;
		}
		.btn {
			width: 300rpx;
			height: 80rpx;
			line-height: 80rpx;
			margin: 0 auto;
			text-align: center;
			color: #fff;
			font-size: 28rpx;
			background: #1C41F1;
			border-radius: 54rpx;
		}
	}
}
</style>
